<include file="Public/header"/>
<div id="tool_bar">
    <div class="plugin"></div>
    <div class="search r">
    </div>
</div>
<div id="page_body">
    <div class="main_warp" id="main_warp">
        <div class="main_body" id="main_body">  

            <div class="mod space">
                <div class="m_bd">
                    <div class="form">
                        <form method="POST" action="{:U('Home/Bookgoods/book_goods')}" style="margin:0">
                            <div class="m_head" align="center">  
                                <div style="padding-top: 20px;padding-bottom: 20px">
                                    <table border="1" id="datatable">
                                        <tr>
                                            <th colspan="5">货物清单</th>
                                        </tr>
                                        <tr>
                                            <th>名称</th>
                                            <th>单价</th>
                                            <th>数量</th>
                                            <th>总价</th>
                                            <th>备注</th>
                                        </tr>
                                        <volist name="goodsList" id="goodsList">
                                            <if condition="$goodsList.goodsname neq ''">
                                                <tr>
                                                    <td width="100px" align="center"><input id="goodsname_<{$goodsList.id}>" type='text' name='goodsname[{$goodsList.id}]' class="text" value='{$goodsList.goodsname}' style="border: 0px;text-align: center" readonly/></td>
                                                    <td width="100px" align="center"><input id="goodsprice_<{$goodsList.id}>" type='text' name='goodsprice[{$goodsList.id}]' class="text" value='{$goodsList.goodsprice}' style="border: 0px;text-align: center" readonly/></td>
                                                    <td width="100px" align="center"><input id="goodsnum_<{$goodsList.id}>" type='text' name='goodsnum[{$goodsList.id}]' class="in_text" value="0" style="width: 70px;text-align: center"/></td>
                                                    <td width="100px" align="center"><input id="goodsmoney_<{$goodsList.id}>" type='text' name='goodsmoney[{$goodsList.id}]' class="text" value='0' data-type='goodsmoney' style="border: 0px;text-align: center" readonly/></td>                          
                                                    <td width="100px" align="center"><input id="goodsremark_<{$goodsList.id}>" type='text' name='goodsremark[{$goodsList.id}]' class="text" value='{$goodsList.remark}' style="border: 0px;text-align: center" readonly/></td>
                                                </tr>     
                                            </if>
                                        </volist>>           
                                        <tr>
                                            <th colspan="5"><span>总价：</span><input id="total" type='text' name='total' class="text" value='0' style=" border: 0px;text-align: center" readonly/></th>
                                        </tr>
                                    </table>
                                    <INPUT TYPE="submit" class="button" value="提交" style="margin-top: 40px;padding-left: 20px;padding-right: 20px;padding-bottom: 10px;padding-top: 10px"/>
                                </div>
                            </div>
                            <hr style="color: black" />

                        </form>
                    </div>

                </div>

            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $("td input", $("#datatable")).keyup(function(event) {
            var target = $(event.target);
            var num = target.val();
            var price = target.parent().prev().find("input").val();
            target.parent().next().find("input").val(parseFloat(num * price).toFixed(2));
            var total = 0;
            $("td input[data-type=goodsmoney]", $("#datatable")).each(function() {
                total = total + parseFloat($(this).val());
            });
            document.getElementById("total").value = total;
            //$("#total").html(total);
        });
    });

</script>

<include file="Public/footer"/>